using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections;
using System.Data.SqlClient;

/// <summary>
/// Summary description for LichRanhDAO
/// </summary>
public class LichRanhDAO:DataProvider
{
    public ArrayList LayMang_LichRanh()
    {
        connect();
        ArrayList arr = new ArrayList();
        try
        {
            SqlCommand cmd = new SqlCommand("sp_Select_LichRanh", strCnn);
            cmd.CommandType = CommandType.StoredProcedure;
            SqlDataReader dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                LichRanhDTO lrdto = new LichRanhDTO();
                lrdto.MaRanh=dr.GetInt32(0);
                lrdto.MaGV = dr.GetString(1);
                lrdto.Ca = dr.GetInt32(2);
                lrdto.Thu = dr.GetString(3);
                lrdto.HocKy = dr.GetString(4);                
                arr.Add(lrdto);
            }
        }
        catch (Exception es)
        {
            throw es;
        }
        return arr;
    }
    public void insert(LichRanhDTO lrdto)
    {
        connect();
        try
        {
            SqlCommand cmd = new SqlCommand("sp_Insert_LichRanh", strCnn);
            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.Add("@magv", SqlDbType.VarChar);
            cmd.Parameters["@magv"].Value = lrdto.MaGV.ToString();
            cmd.Parameters["@magv"].Direction = ParameterDirection.Input;

            cmd.Parameters.Add("@ca", SqlDbType.Int);
            cmd.Parameters["@ca"].Value = lrdto.Ca;
            cmd.Parameters["@ca"].Direction = ParameterDirection.Input;

            cmd.Parameters.Add("@thu", SqlDbType.VarChar);
            cmd.Parameters["@thu"].Value = lrdto.Thu.ToString();
            cmd.Parameters["@thu"].Direction = ParameterDirection.Input;

            cmd.Parameters.Add("@hocky",SqlDbType.VarChar);
            cmd.Parameters["@hocky"].Value = lrdto.HocKy.ToString();
            cmd.Parameters["@hocky"].Direction = ParameterDirection.Input;


            cmd.ExecuteNonQuery();
        }
        catch (Exception es)
        {
            throw es;
        }
    }
    public void update(LichRanhDTO lrdto)
    {
        connect();
        try
        {
            SqlCommand cmd = new SqlCommand("sp_Update_LichRanh", strCnn);
            cmd.CommandType = CommandType.StoredProcedure;

            cmd.Parameters.Add("@maranh", SqlDbType.Int);
            cmd.Parameters["@maranh"].Value = lrdto.MaRanh;
            cmd.Parameters["@maranh"].Direction = ParameterDirection.Input;

            cmd.Parameters.Add("@magv", SqlDbType.VarChar);
            cmd.Parameters["@magv"].Value = lrdto.MaGV.ToString();
            cmd.Parameters["@magv"].Direction = ParameterDirection.Input;

            cmd.Parameters.Add("@ca", SqlDbType.Int);
            cmd.Parameters["@ca"].Value = lrdto.Ca;
            cmd.Parameters["@ca"].Direction = ParameterDirection.Input;

            cmd.Parameters.Add("@thu", SqlDbType.VarChar);
            cmd.Parameters["@thu"].Value = lrdto.Thu.ToString();
            cmd.Parameters["@thu"].Direction = ParameterDirection.Input;

            cmd.Parameters.Add("@hocky", SqlDbType.VarChar);
            cmd.Parameters["@hocky"].Value = lrdto.HocKy.ToString();
            cmd.Parameters["@hocky"].Direction = ParameterDirection.Input;

            cmd.ExecuteNonQuery();
        }
        catch (System.Exception ex)
        {
            throw ex;
        }
    }
	public LichRanhDAO()
	{
		//
		// TODO: Add constructor logic here
		//
	}
}
